
/**
 * 所有的ajax服务调用
 */
CommonService = {
	'getAllProvince': function(){
		var lst_param = new Array();
		var str_param = lst_param.join('&');
		var result = null;

		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getAllProvince',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;

			},
			error : function(e, err_name, err_text) {
				result = {};
				result.IsSuccess = 0;
				result.ErrorMsg = err_text;
				result.ErrorCode = 4;
				
			}
		});
		return result;
	},
	'getCityListByProvinceId': function(province_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('province_id=' + province_id);
		var str_param = lst_param.join('&');


		var result = null;

		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getCityListByProvinceId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;

			},
			error : function(e, err_name, err_text) {
				result = {};
				result.IsSuccess = 0;
				result.ErrorMsg = err_text;
				result.ErrorCode = 4;
			}
		});
		return result;
	},
	'getDistrictListByCityId': function(city_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('city_id=' + city_id);
		var str_param = lst_param.join('&');

		var result = null;
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getDistrictListByCityId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;

			},
			error : function(e, err_name, err_text) {
				result = {};
				result.IsSuccess = 0;
				result.ErrorMsg = err_text;
				result.ErrorCode = 4;
			}
		});
		return result;
	},
}


AdminService = {
	'Login' : function(user_id, pwd) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('user_id=' + user_id);
		lst_param.push('password=' + pwd);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/login',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'Logout' : function(user_id, pwd) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('user_id=' + user_id);
		var str_param = lst_param.join('&');
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/logout',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
        	  error : function(e, err_name, err_text) {
        		  result = {};
        		  result.IsSuccess = 0;
        		  result.ErrorMsg = err_text;
        		  result.ErrorCode = 4;
        	  }
		});
		return result;
	},
};

OrderService = {
   'Order': function(thirdOrderId,receiverMobile, orderId, 
		   reveiverAdd, orderStartDate, orderEndDate,orderStatus,cashBackStatus,invoiceKind,invoiceStatus,consigneeName,message,orderType,invoiceDate,orderEndTime,orderEndTimeEnd,index,pageSize,_successFun) {
		// 查询订单功能
	   
		var lst_param = new Array();
		lst_param.push('third_order_id=' + thirdOrderId);
		lst_param.push('order_id=' + orderId);
		lst_param.push('consignee_address=' + reveiverAdd);
		lst_param.push('order_date=' + orderStartDate);
		lst_param.push('order_end_time=' + orderEndDate);
		lst_param.push('taobao_order_status='+ orderStatus);
		lst_param.push('cash_back_status='+ cashBackStatus);
		lst_param.push('invoice_kind='+ invoiceKind);
		lst_param.push('invoice_status='+ invoiceStatus);
		lst_param.push('message='+ message);
		lst_param.push('receiver_mobile='+ receiverMobile);
		lst_param.push('consignee_name='+ consigneeName);
		lst_param.push('orderType='+ orderType);
		lst_param.push('invoiceDate='+invoiceDate);
		lst_param.push('orderEndTime='+orderEndTime);
		lst_param.push('orderEndTimeEnd='+orderEndTimeEnd);
		lst_param.push('index='+ index);
		lst_param.push('pageSize='+ pageSize);
		
		var str_param = lst_param.join('&');

		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/order/orderQuery',
			data : str_param,
			dataType : 'json',
			async : true,//改异步并嵌入返回方法
			success : _successFun,
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    		  _successFun(result);
    	  }
		});
		
		return result;
	},
	'UpdateInvoiceTitle': function(thirdOrderId,invoiceTitle) {
			// 查询订单功能
			var lst_param = new Array();
			lst_param.push('third_order_id=' + thirdOrderId);
			lst_param.push('invoice_title=' + invoiceTitle);
			
			var str_param = lst_param.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/updateInvoiceTitle',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			
			return result;
		},
		
	//修改发票地址
	'UpdateInvoiceAddress': function(thirdOrderId,invoiceAddress) {
		var lst_param = new Array();
		lst_param.push('third_order_id=' + thirdOrderId);
		lst_param.push('invoice_address=' + invoiceAddress);
		var str_param = lst_param.join('&');
		var result = null;
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/order/updateinvoiceaddress',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		
		return result;
	},
		
	'UpdateInvoiceKind': function(thirdOrderId,invoiceKind) {
			// 查询订单功能
		   
		
			var lst_param = new Array();
			lst_param.push('third_order_id=' + thirdOrderId);
			lst_param.push('invoice_Kind=' + invoiceKind);
			
			var str_param = lst_param.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/updateInvoiceKind',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			
			return result;
		}
};


InvoiceService = {
		   'Invoice': function(thirdOrderIds, orderStartDate, orderEndDate,cashBackStatus,message,orderType,index,pageSize) {
				// 查询订单功能
			   
				var lst_param = new Array();
				lst_param.push('third_order_ids=' + thirdOrderIds);
				lst_param.push('order_date=' + orderStartDate);
				lst_param.push('order_end_time=' + orderEndDate);
				lst_param.push('cash_back_status=' + cashBackStatus);
				lst_param.push('message=' + message);
				lst_param.push('order_type=' + orderType);
				lst_param.push('index='+ index);
				lst_param.push('pageSize='+ pageSize);
				
				var str_param = lst_param.join('&');

				var result = null;
				
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/order/invoiceQuery',
					data : str_param,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		        	  error : function(e, err_name, err_text) {
		        		  result = {};
		        		  result.IsSuccess = 0;
		        		  result.ErrorMsg = err_text;
		        		  result.ErrorCode = 4;
		        	  }
				});
				
				return result;
			},
			   'UpdateInvoiceName': function(thirdOrderIds) {
					// 查询订单功能
					var lst_param = new Array();
					lst_param.push('third_order_ids=' + thirdOrderIds);
					var str_param = lst_param.join('&');

					var result = null;
					
					$.ajax({
						type : 'post',
						url : '/AjaxService/center/order/updateInvoiceName',
						data : str_param,
						dataType : 'json',
						async : false,
						success : function(data) {
							result = data;
						},
			        	  error : function(e, err_name, err_text) {
			        		  result = {};
			        		  result.IsSuccess = 0;
			        		  result.ErrorMsg = err_text;
			        		  result.ErrorCode = 4;
			        	  }
					});
					
					return result;
				},
       'ApplyInvoice': function(orderIds, invoice_type) {
    	   //开发票
	       var lst_param = new Array();
	          lst_param.push('order_ids=' + orderIds);
	          lst_param.push('invoice_type=' + invoice_type);
	          var str_param = lst_param.join('&');
	          var result = null;
	
	          $.ajax({
	        	  type : 'post',
	        	  url : '/AjaxService/center/order/openInvoice',
	        	  data : str_param,
	        	  dataType : 'json',
	        	  async : false,
	        	  success : function(data) {
	        		  result = data;
	        	  },
	        	  error : function(e, err_name, err_text) {
	        		  result = {};
	        		  result.IsSuccess = 0;
	        		  result.ErrorMsg = err_text;
	        		  result.ErrorCode = 4;
	        	  }
	          });
	
	          return result;
       },
       
       'redInvoice': function(orderId, redReason) {
    	   //开发票
	       var lst_param = new Array();
	          lst_param.push('order_id=' + orderId);
	          lst_param.push('red_reason=' + redReason);
	          var str_param = lst_param.join('&');
	          var result = null;
	
	          $.ajax({
	        	  type : 'post',
	        	  url : '/AjaxService/center/order/redInvoice',
	        	  data : str_param,
	        	  dataType : 'json',
	        	  async : false,
	        	  success : function(data) {
	        		  result = data;
	        	  },
	        	  error : function(e, err_name, err_text) {
	        		  result = {};
	        		  result.IsSuccess = 0;
	        		  result.ErrorMsg = err_text;
	        		  result.ErrorCode = 4;
	        	  }
	          });
	
	          return result;
       }

};

